package com.winit.menu.model;

import com.winit.common.util.treeUtils.NodeElement;
import com.winit.common.util.treeUtils.NodeType;
import io.swagger.annotations.ApiModelProperty;
import org.springframework.data.annotation.Transient;
import org.springframework.data.cassandra.mapping.Column;
import org.springframework.data.cassandra.mapping.PrimaryKey;
import org.springframework.data.cassandra.mapping.Table;
import org.springframework.util.StringUtils;

import java.util.List;
import java.util.Map;

/**
 * Created by wangjian on 2017/11/22.
 */
@NodeType(name = "menu")
@Table(value = "matrix_menu")
public class MatrixMenu {
    @NodeElement(name = {"id"})
    @PrimaryKey
    @Column(value = "id")
    private String id;
//    @ApiModelProperty(hidden = true)
//    @Column(value = "menu_id")
//    private String menu_id;

    @Column(value = "level")
    private String level;
    /**
     * 不关注
     */
    @Column(value = "status")
    private String status;
    @ApiModelProperty(hidden = true)
    @Column(value = "children")
    private List<String> children;
    @Column(value = "sys")
    private String sys;
    @NodeElement(name = {"parentId"})
    @Column(value = "parent_id")
    private String parent_id;
    /**
     * 查的时候只过滤它
     */
    @Column(value = "is_del")
    private String is_del;
    @Column(value = "req_id")
    private String req_id;
    @Column(value = "menu_data")
    private Map<String, String> menu_data;
    @NodeElement(name = {"name"})
    @Column(value = "menu_name")
    private String menu_name;
    @Column(value = "menu_num")
    private String menuNum;


    @ApiModelProperty(hidden = true)
    @Transient
    private List<MatrixMenu> child;

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

//    public String getMenu_id() {
//        return menu_id;
//    }
//
//    public void setMenu_id(String menu_id) {
//        this.menu_id = menu_id;
//    }


    public String getLevel() {
        return level;
    }

    public void setLevel(String level) {
        this.level = level;
    }

    public List<String> getChildren() {
        return children;
    }

    public void setChildren(List<String> children) {
        this.children = children;
    }

    public String getSys() {
        return sys;
    }

    public void setSys(String sys) {
        this.sys = sys;
    }


    public String getParent_id() {
        return parent_id;
    }

    public void setParent_id(String parent_id) {
        this.parent_id = parent_id;
    }

    public String getIs_del() {
        return is_del;
    }

    public void setIs_del(String is_del) {
        this.is_del = is_del;
    }

    public String getReq_id() {
        return req_id;
    }

    public void setReq_id(String req_id) {
        this.req_id = req_id;
    }

    public List<MatrixMenu> getChild() {
        return child;
    }

    public void setChild(List<MatrixMenu> child) {
        this.child = child;

    }


    public String getStatus() {
        return status;
    }

    public void setStatus(String status) {
        this.status = status;
    }

    public Map<String, String> getMenu_data() {
        return menu_data;
    }

    public void setMenu_data(Map<String, String> menu_data) {
        this.menu_data = menu_data;
    }

    public String getMenu_name() {
        return menu_name;
    }

    public String getMenuNum() {
        return menuNum;
    }

    public void setMenuNum(String menuNum) {
        this.menuNum = menuNum;
    }

    public void setMenu_name(String menu_name) {
        if (StringUtils.isEmpty(menu_name) && this.menu_data != null) {
            menu_name = this.menu_data.get("name");
        }

        this.menu_name = menu_name;
    }
}
